
import { PageEnum } from '@/enums/pageEnum';
import {RouteRecordRaw } from 'vue-router';

const whiteList:Array<RouteRecordRaw> = [
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/view/login/login.vue')
    }
]

const RootRoutes:Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'Root',
        redirect: PageEnum.BASE_LOGIN,
        meta: {
            title: 'Root'
        }
    }
]

const modules = import.meta.glob('./modules/**/*.ts',{eager:true})
const routeModuleList: RouteRecordRaw[] = []

Object.keys(modules).forEach((key: string) => {
    // @ts-ignore
    const mod = modules[key].default || {}
    const modList = Array.isArray(mod) ? [...mod] : [mod]
    routeModuleList.push(...modList)
})
 
const routes: Array<RouteRecordRaw> = [
    ...RootRoutes,
    ...whiteList,
    ...routeModuleList
];
 
export default routes;